package com.iut.quizz;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

// ^(?!.*(nativeGetEnabledTags)).*$

public class MenuApp extends Activity implements OnClickListener {

	private Button butPlay = null;
	private Button butExit = null;

	/**
	 * When App is created
	 * 
	 * @param savedInstanceState
	 *            States of the app
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.menu);

		this.initMenu();
	}

	/**
	 * Event when user Click of the send Button
	 * 
	 * @param arg0
	 *            The view of the App
	 */
	@Override
	public void onClick(View arg0) {
		try {
			if (arg0.getId() == R.id.butPlay) {
				Intent game = new Intent(this, App.class);
				startActivity(game);
			} else {
				System.exit(0);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	/**
	 * 
	 * @param Menu Menu of the app
	 * @return boolean
	 */
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public void initMenu() {
		this.setButPlay((Button) findViewById(R.id.butPlay));
		this.setButExit((Button) findViewById(R.id.butExit));

		this.getButPlay().setOnClickListener(this);
		this.getButExit().setOnClickListener(this);

	}

	public Button getButPlay() {
		return butPlay;
	}

	public void setButPlay(Button butPlay) {
		this.butPlay = butPlay;
	}

	public Button getButExit() {
		return butExit;
	}

	public void setButExit(Button butExit) {
		this.butExit = butExit;
	}

}
